package LinkedListPackage;

import java.util.List;

/**
 * @author Lzm
 * @version 1.0
 */
public class reverseList_ {
  ListNode head;
  ListNode temp1 = null;
  ListNode temp2 = head;

  public ListNode reverseList(ListNode head) {
    if (head == null){
      return null;
    }
      ListNode dummyHead = new ListNode();
      ListNode temp1 = null;
      ListNode temp2 = head;
      while(temp2 != null){
        ListNode temp = temp2.next;
        temp2.next = temp1;
        temp1 = temp2;
        temp2 = temp;
      }
      return temp1;
  }

  public ListNode reverseList1(ListNode temp1,ListNode temp2) {

    if (temp2 == null){
      return temp1;
    }
    ListNode temp = null;
    temp = temp2.next;
    temp2.next = temp1;
    reverseList1(temp2,temp);
    return temp1;
  }
}
